args credit_score ltv

// Bins for credit score
gen credit_score_bin = 0 if `credit_score' < 620
local z = 0
foreach n of numlist 620(20)720 {
	local z = `z' + 1
	replace credit_score_bin = `z' if inrange(`credit_score', `n', `n'+19)
}
replace credit_score_bin = `z' + 1 if `credit_score' >= 740


// Bins for LTV
gen ltv_bin = 0 if `ltv' <= 60
replace ltv_bin = 1 if `ltv'>60 & `ltv' <= 70
local z = 1
foreach n of numlist 70(5)90 {
	local z = `z' + 1
	replace ltv_bin = `z' if `ltv' > `n' & `ltv' <= `n'+5
}
replace ltv_bin = `z' + 1 if `ltv' > 95 & `ltv' <= 97
replace ltv_bin = `z' + 2 if `ltv' > 97 


